// 4个
var option = {
  legend: {},
  tooltip: {},
  title: [
    {
      text: '标题adfadfadfdfada',
      left: 'center',
      textStyle: {
        color: '#000',
        fontSize: 26
      },
      top: '0'
    },
    {
      x: '35%',
      text: '同',
      y: '50%'
    },
    {
      x: '35%',
      text: '同',
      bottom: '0'
    },
    {
      x: '65%',
      text: '同',
      y: '50%'
    },
    {
      left: '65%',
      text: '同',
      bottom: '0'
    }
  ],
  toolbox: {
    show: true,
    orient: 'vertical',
    y: 'center',
    right: '10px',
    feature: {
      make: { show: true },
      dataView: { show: true, readOnly: false },
      magicType: { show: true, type: ['line', 'bar'] },
      restore: { show: true },
      saveAsImage: { show: true }
    }
  },
  dataset: {
    source: [
      ['product', '2012', '2013', '2014', '2015', '2016', '2017'],
      ['Matcha Latte', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7],
      ['Milk Tea', 86.5, 92.1, 85.7, 83.1, 73.4, 55.1]
      // ['Cheese Cocoa', 24.1, 67.2, 79.5, 86.4, 65.2, 82.5],
      // ['Walnut Brownie', 55.2, 67.1, 69.2, 72.4, 53.9, 39.1]
    ]
  },
  series: [
    {
      name: '访问来源',
      type: 'pie',
      selectedMode: 'single',
      radius: [0, '30%'],
      center: ['35%', '30%'],
      label: {
        position: 'inner'
      },
      labelLine: {
        show: false
      },
      data: [
        { value: 335, name: '直达', selected: true },
        { value: 679, name: '营销广告' },
        { value: 1548, name: '搜索引擎' }
      ]
    },
    {
      name: '访问来源',
      type: 'pie',
      radius: [0, '30%'],
      center: ['65%', '30%'],
      label: {
        position: 'inner'
      },
      labelLine: {
        show: false
      },
      data: [
        { value: 335, name: '直达', selected: true },
        { value: 679, name: '营销广告' },
        { value: 1548, name: '搜索引擎' }
      ]
    },
    {
      name: '访问来源',
      type: 'pie',
      radius: [0, '30%'],
      center: ['65%', '75%'],
      label: {
        position: 'inner'
      },
      labelLine: {
        show: false
      },
      data: [
        { value: 335, name: '直达', selected: true },
        { value: 679, name: '营销广告' },
        { value: 1548, name: '搜索引擎' }
      ]
    },
    {
      type: 'pie',
      radius: [0, '30%'],
      center: ['35%', '75%'],
      label: {
        position: 'inner'
      },
      labelLine: {
        show: false
      },
      data: [
        { value: 335, name: '直达', selected: true },
        { value: 679, name: '营销广告' },
        { value: 1548, name: '搜索引擎' }
      ]
    }
  // , {
  //     type: 'pie',
  //     radius: 60,
  //     center: ['75%', '75%'],
  //     encode: {
  //         itemName: 'product',
  //         value: '2015'
  //     }
  // }
  ]
}

// 1个
option = {
  tooltip: {
    trigger: 'item',
    formatter: '{a} <br/>{b}: {c} ({d}%)'
  },
  toolbox: {
    show: true,
    orient: 'vertical',
    y: 'center',
    right: '10px',
    feature: {
      make: { show: true },
      dataView: { show: true, readOnly: false },
      magicType: { show: true, type: ['line', 'bar'] },
      restore: { show: true },
      saveAsImage: { show: true }
    }
  },
  title: [
    {
      text: '标题',
      left: 'center',
      textStyle: {
        color: '#000',
        fontSize: 26
      },
      top: '15%'
    },
    {
      left: '48%',
      text: '同济大学',
      bottom: '15%'
    }
  ],
  legend: {
    orient: 'vertical',
    left: 10,
    data: ['直达', '营销广告', '搜索引擎']
  },
  series: [
    {
      name: '访问来源',
      type: 'pie',
      selectedMode: 'single',
      radius: [0, '30%'],
      label: {
        position: 'inner'
      },
      labelLine: {
        show: false
      },
      data: [
        { value: 335, name: '直达', selected: true },
        { value: 679, name: '营销广告' },
        { value: 1548, name: '搜索引擎' }
      ]
    }
  ]
}

var series = [
  {
    text: '标题1',
    count: 1,
    total: 8
  },
  {
    text: '标题2fadfadfasdfd',
    count: 2,
    total: 80
  },
  {
    text: '标题3adfafdasdfadfasdf',
    count: 3,
    total: 18
  },
  {
    text: '复旦大学',
    count: 5,
    total: 18
  }
]
option = {
  title: [
    {
      left: 'center',
      y: '10%',
      textStyle: {
        color: '#000',
        fontSize: 26
      },
      text: '大标题'

    }],
  // color: ["#bf61d4", "#03a9f4", "#2fc25b", "#fbc02d"],
  tooltip: {
    trigger: 'item',
    formatter: '{a}<br/>{b}:{c}({d}%)'
  },
  toolbox: {
    show: true,
    orient: 'vertical',
    y: 'center',
    right: '10px',
    feature: {
      make: { show: true },
      dataView: { show: true, readOnly: false },
      magicType: { show: true, type: ['line', 'bar'] },
      restore: { show: true },
      saveAsImage: { show: true }
    }
  },
  series: []
}
for (let i = 0; i < series.length; i++) {
  option.title[i + 1] = {
    // text: series[i].text,
    text: '{pp|' + series[i].text + '}',
    left: (i + 1) * 19 - 4 + '%',
    y: '70%',
    textStyle: {
      fontSize: 15,
      rich: {
        pp: {
          fontWeight: 'bold',
          fontSize: 15,
          width: '9',
          align: 'center'
        }
      }
    },
    // subtext: series[i].count,
    subtext: '{pp|' + series[i].count + '}',
    itemGap: 200,
    subtextStyle: {
      fontSize: 15,
      color: 'black',
      VerticalAlign: 'top',
      rich: {
        pp: {
          fontSize: 15,
          fontWeight: 'bold',
          width: '9',
          align: 'center'
        }
      }
    }
  }

  option.series[i] = {
    name: '党员分布',
    type: 'pie',
    center: [(i + 1) * 19 + '%', '50%'],
    radius: [0, '30%'],
    label: {
      normal: {
        formatter: function (params) {
          console.log(params)
          return params.name + ':' + params.percent + '%'
        }
      },
      position: 'inner'
    },
    labelLine: {
      show: false
    },
    data: [
      { value: 335, name: '直达', selected: true },
      { value: 679, name: '营销广告' },
      { value: 1548, name: '搜索引擎' }
    ]
  }
}
